﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DSkin;
using DSkin.Forms;
using System.IO;

namespace wfaResClient
{
    public partial class FrmSetting : DSkinForm
    {
        public FrmSetting()
        {
            InitializeComponent();
        }
        DeviceControl dc = new DeviceControl();
        private void dSkinButton2_Click(object sender, EventArgs e)//保存本地化配置
        {
            
            Properties.Settings.Default.DefaultCallingNumber = dSkinTextBox2.Text;//保存默认呼叫号码
            Properties.Settings.Default.Save();
            Properties.Settings.Default.RecordingUrl = dSkinTextBox1.Text;//设置当前路径为程序启动路径
            Properties.Settings.Default.Save();
        }

        private void dSkinCheckBox1_CheckedChanged(object sender, EventArgs e)//启动软件打开设备
        {
            if (dSkinCheckBox1.Checked == true)
            {
                Properties.Settings.Default.SelfStartingEquipment = 1;//更新本地保存字段。自启设备
                Properties.Settings.Default.Save();
            }
            else
            {
                Properties.Settings.Default.SelfStartingEquipment = 0;//不自启
                Properties.Settings.Default.Save();
            }
        }

        private void dSkinCheckBox2_CheckedChanged(object sender, EventArgs e)//呼叫外线加09
        {
            if (dSkinCheckBox2.Checked == true)
            {
                Properties.Settings.Default.CallOutside = 1;//自动呼叫外线添加09
                Properties.Settings.Default.Save();
            }
            else
            {
                Properties.Settings.Default.CallOutside = 0;
                Properties.Settings.Default.Save();
            }
        }

        private void dSkinCheckBox3_CheckedChanged(object sender, EventArgs e)//呼叫外地号码自动加0
        {
            if (dSkinCheckBox3.Checked == true)
            {
                Properties.Settings.Default.CallForeignNumber = 1;//呼叫外地号码添加0
                Properties.Settings.Default.Save();
            }
            else
            {
                Properties.Settings.Default.CallForeignNumber = 0;
                Properties.Settings.Default.Save();
            }
        }

        private void dSkinCheckBox4_CheckedChanged(object sender, EventArgs e)//自动录音
        {
            if (dSkinCheckBox4.Checked == true)
            {
                Properties.Settings.Default.AutomaticRecording = 1;//自动录音
                Properties.Settings.Default.Save();
            }
            else
            {
                Properties.Settings.Default.AutomaticRecording = 0;//自动录音
                Properties.Settings.Default.Save();
            }
        }
        private void FrmSetting_Load(object sender, EventArgs e)//窗体加载
        {
            if (Properties.Settings.Default.SelfStartingEquipment == 1)
                dSkinCheckBox1.Checked = true;
            else
                dSkinCheckBox1.Checked = false;
            if (Properties.Settings.Default.CallOutside == 1)
                dSkinCheckBox2.Checked = true;
            else
                dSkinCheckBox2.Checked = false;
            if (Properties.Settings.Default.CallForeignNumber == 1)
                dSkinCheckBox3.Checked = true;
            else
                dSkinCheckBox3.Checked = false;
            if (Properties.Settings.Default.SelfStartingEquipment == 1)
                dSkinCheckBox4.Checked = true;
            else
                dSkinCheckBox4.Checked = false;
            dSkinTextBox1.Text = Properties.Settings.Default.RecordingUrl;//加载默认保存的录音路径
            dSkinTextBox2.Text = Properties.Settings.Default.DefaultCallingNumber;//加载保存的默认号码
            DskinValue.Value =Convert.ToInt32(Properties.Settings.Default.RecordingValue);
        }
        private void dSkinButton1_Click(object sender, EventArgs e)//自定义保存路径
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            fbd.Description = "请选择保存路径";
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                string filePath = fbd.SelectedPath;//选择保存的路径
                dSkinTextBox1.Text = filePath;//显示路径
            }
        }
        private void DskinValue_ValueChanged(object sender, EventArgs e)
        {
            lblRecValue.Text = DskinValue.Value.ToString();
            Properties.Settings.Default.RecordingValue= DskinValue.Value.ToString();//记录保存录音音量的值
            Properties.Settings.Default.Save();
        }

    }
}
